<html>
<meta http-equiv="content-Type" content="text/html; charset=utf-8"/>
<style>
.docSoBtn{
display:inline-block;
background:#7fb133;
background:-moz-linear-gradient(top,#99ca4b 0,#66991c 100%);
background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#99ca4b),color-stop(100%,#66991c));
background:-webkit-linear-gradient(top,#99ca4b 0,#66991c 100%);
background:-o-linear-gradient(top,#99ca4b 0,#66991c 100%);
background:-ms-linear-gradient(top,#99ca4b 0,#66991c 100%);
filter:progid:DXImageTransform.Microsoft.gradient(enabled='true',startColorstr='#99ca4b',endColorstr='#66991c',GradientType=0);
background:linear-gradient(top,#99ca4b 0,#66991c 100%);
-moz-border-radius:5px;
-webkit-border-radius:5px;
border-radius:5px;
-moz-background-clip:padding;
-webkit-background-clip:padding-box;
background-clip:padding-box;
-moz-background-clip:padding;
-webkit-background-clip:padding-box;
background-clip:padding-box;
font-family:arial;
font-weight:bold;
text-decoration:none;
color:white;
border:1px solid #668f28;
-webkit-box-shadow:inset 0 1px 1px #cde7a4;
box-shadow:inset 0 1px 1px #cde7a4;
text-shadow:0 -1px 1px #5a8a11;
line-height:1;
text-align:center;
padding:5px 15px;
}
.docSoBtn:hover{background:#a3d061;
_background:#7fb133;background:-moz-linear-gradient(top,#bde086 0,#85bc34 100%);
background:-webkit-gradient(linear,left top,left bottom,color-stop(0%,#bde086),color-stop(100%,#85bc34));
background:-webkit-linear-gradient(top,#bde086 0,#85bc34 100%);
background:-o-linear-gradient(top,#bde086 0,#85bc34 100%);
background:-ms-linear-gradient(top,#bde086 0,#85bc34 100%);
filter:progid:DXImageTransform.Microsoft.gradient(enabled='true',startColorstr='#bde086',endColorstr='#85bc34',GradientType=0);
background:linear-gradient(top,#bde086 0,#85bc34 100%);
border:1px solid #9abf64;
_border:1px solid #668f28;
-webkit-box-shadow:inset 0 1px 1px #d5ebb1;
box-shadow:inset 0 1px 1px #d5ebb1;
text-shadow:0 -1px 1px #7fb134;
text-decoration:none;
padding:5px 15px;
cursor:pointer;
}

</style>
<body>
<?php
if(isset($_POST["so"]))
{
	function docSo($so)
	{
		switch($so)
		{
			case 0:
				$chu = "Không";
				break;
			case 1:
				$chu = "một";
				break;
			case 2:
				$chu = "hai";
				break;
			case 3:
				$chu = "ba";
				break;
			case 4:
				$chu = "bốn";
				break;
			case 5:
				$chu = "năm";
				break;
			case 6:
				$chu = "sáu";
				break;
			case 7:
				$chu = "bảy";
				break;
			case 8:
				$chu = "tám";
				break;
			case 9:
				$chu = "chín";
				break;
		}
		return $chu;
	}
	
	$so = $_POST["so"];
	$dv = $so%10;
	$chuc = (int)$so/10;
	$chuc = $chuc % 10;
	$tram = (int)($so/100);
	$docChuc = "";
	$docDV = "";
	$docTram = "";
	$ketqua = "";
	if($so == 0)
	{
		$ketqua = "không";
	}
	else
	{
		if($tram == 0 )
		{
			$docTram = "";
		}
		
		else
		{
			$docTram = docSo($tram)." trăm";
		}
		if($chuc == 0)
		{
			if($dv != 0)
			{
				$docChuc = "lẻ";
				$docDV = docSo($dv);
			}
		}
		else
		{
			if($dv == 0)
			{
				$docDv = "";
				$docChuc = docSo($chuc)." mươi";
			}				
			else if($dv == 1)
			{
				$docDV = "mốt";
			}
			else if($dv == 5)
			{
				$docDV = "lăm";
			}
			else
			{
				$docDV = docSo($dv);
			}
			if($chuc == 1){
				$docChuc = "mười";
				if($dv == 1)
				{
					$docDV = "một";
				}
			}
			else
			{
				$docChuc = docSo($chuc)." mươi";
			}
		}
	}
$ketqua = $docTram." ".$docChuc." ".$docDV;
	
}
?>


<form id = "form1" name="form1" method="post" action="docSo.php">
<table align = "center">

<tr>
<td colspan="2" align="center"><span>ĐỌC SỐ</span></td>
</tr>


<tr>

<td><span>mời nhập số </span></td>

<td><label><input name="so" id="so" type="text" value="<?php
if(isset($_POST["so"]))
{
	echo $_POST["so"];
}
?>
"/></label></td>

</tr>

<tr>
<td colspan="2"align="center"><label><input class="docSoBtn"name="tinh"id="tinh"type="submit" value="Đọc Số"/></label></td>
</tr>

<tr>
<td colspan="2"align="center"><label><input id="ketqua"name="ketqua"type="text"value="<?php 
if(isset($_POST["ketqua"]))
{
	echo $ketqua;
}

?>"/></label></td>
</tr>

</table>
</form>








</body>

</html>